package cn.com.dycc.sys_manage.post.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.dycc.common.controller.BaseController;
import cn.com.dycc.sys_manage.post.entity.PostEntity;
import cn.com.dycc.sys_manage.post.param.FindListPostParam;
import cn.com.dycc.sys_manage.post.param.PostParam;
import cn.com.dycc.sys_manage.post.service.PostService;
import cn.com.dycc.util.JsonObjectResult;

@Controller
@RequestMapping("post")
public class PostController extends BaseController{
	
	@Resource(name="postService")
	private PostService postService;
	
	//增加岗位信息
	@RequestMapping("add.do")
	@ResponseBody
	public JsonObjectResult addPost(HttpServletRequest request,PostParam postParam){
//		System.out.println("postParam="+postParam);
		String mes = postService.addPost(request, postParam);
		return new JsonObjectResult(mes);
	}
	
	//查询所有的岗位信息
	@RequestMapping("find.do")
	@ResponseBody
	public JsonObjectResult findPostAll(HttpServletRequest request,FindListPostParam findListPostParam){
		List<PostEntity> list = postService.findPostAll(request, findListPostParam);
		String count = postService.findPostAllCount(request, findListPostParam);
		return new JsonObjectResult(count,list);
	}
	
	//更新岗位信息
	@RequestMapping("update.do")
	@ResponseBody
	public JsonObjectResult updatePost(HttpServletRequest request,PostParam postParam){
		String mes = postService.updatePost(request, postParam);
		return new JsonObjectResult(mes);
	}
	
	//删除岗位
	@RequestMapping("delpost.do")
	@ResponseBody
	public JsonObjectResult delPost(HttpServletRequest request,String id){
		String mes = postService.delPost(request, id);
		return new JsonObjectResult(mes);
	}
}
